/**
 * Licensed to iNet Academy under one or more contributor license
 * agreements. See the NOTICE file distributed with this work
 * for additional information regarding copyright ownership.
 * Open-Ones Group licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a
 * copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package inet.android.buoi2;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class iNETIntentImplicit extends Activity {
	TextView label1;
	EditText text1;
	Button btnCallActivity2;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		try {
			setContentView(R.layout.main);
			label1 = (TextView) findViewById(R.id.label1);
			text1 = (EditText) findViewById(R.id.text1);
			btnCallActivity2 = (Button) findViewById(R.id.btnCallActivity2);
			btnCallActivity2.setOnClickListener(new ClickHandler());
		} catch (Exception e) {
			Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG)
					.show();
		}
	}// onCreate

	private class ClickHandler implements OnClickListener {
		public void onClick(View v) {
			try {

				// ======================================================================
				// this fragments instantiates a second activity to place the
				// phone call
				// example: for ACTION_CALL or ACTION_DIAL use data:
				// "tel:555-1234"
				// for ACTION_VIEW use data: "http://www.youtube.com"
				// you also need INTERNET permission (see Manifest)
				//
				 String myData = text1.getText().toString();
				 Intent myActivity2 = new Intent(Intent.ACTION_DIAL,
				 Uri.parse(myData));
				 startActivity(myActivity2);

				// ----------------------------------------------------------------
				// example of other built-in activities
				// ----------------------------------------------------------------

				// ======================================================================
				// // Google search
				// Intent intent = new Intent (Intent.ACTION_WEB_SEARCH );
				// intent.putExtra(SearchManager.QUERY,
				// "straight hitting golf clubs");
				// startActivity(intent);

				// ======================================================================
				// // sending SMS
				// Intent intent = new Intent(Intent.ACTION_SENDTO,
				// Uri.parse("sms://"));
				// intent.putExtra("address", "555-1234");
				// intent.putExtra("sms_body",
				// "remember to buy bread and milk");
				// startActivity(intent);

				// ======================================================================
				// // google maps & streetview
				// //String geoCode =
				// "geo:0,0?q=1860+east+18th+street+cleveland+oh";
				// //String geoCode = "geo:41.5020952,-81.6789717";
				// String geoCode =
				// "google.streetview:cbll=41.5020952,-81.6789717&cbp=1,270,,45,1&mz=3";
				// Intent intent = new Intent(Intent.ACTION_VIEW,
				// Uri.parse(geoCode));
				// startActivity(intent);

				// ======================================================================
				// //Getting driving directions: use BROWSER then try MAPS
				// Intent intent = new
				// Intent(android.content.Intent.ACTION_VIEW,
				// Uri.parse("http://maps.google.com/maps?saddr=9.938083,-84.054430&daddr=9.926392,-84.055964"));
				// startActivity(intent);

				// ======================================================================
				// // mapping address through mnemonic
				// // (you may get multiple hits)
				// String thePlace = "Cleveland State University";
				// Intent intent = new
				// Intent(android.content.Intent.ACTION_VIEW,
				// Uri.parse("geo:0,0?q=(" + thePlace + ")" ));
				// startActivity(intent);

				// ======================================================================
				// // using GOOGLE STREET-VIEW
				// String geoCode =
				// "google.streetview:cbll=41.5020952,-81.6789717&cbp=1,270,,45,1&mz=1";
				// Intent myIntent = new Intent(Intent.ACTION_VIEW,
				// Uri.parse(geoCode));
				// startActivity(myIntent);

				// ======================================================================
				// // showing pictures
				// Intent myIntent = new Intent();
				// myIntent.setType("image/pictures/*");
				// myIntent.setAction(Intent.ACTION_GET_CONTENT);
				// startActivity(myIntent);

				// ======================================================================
				// // changing the phone's language and keyboard
				// Intent intent = new Intent(Intent.ACTION_MAIN);
				// intent.setClassName("com.android.settings",
				// "com.android.settings.LanguageSettings");
				// startActivity(intent);
				// ======================================================================

			} catch (Exception e) {
				Toast.makeText(getBaseContext(), e.getMessage(),
						Toast.LENGTH_LONG).show();
			}
		}// onClick
	}// ClickHandler
}